<?php
/**
* SocialEngine
*
* @category   Application_Extensions
* @package    Flashgame
* @copyright 2010 YouNet
* @license    http://www.modules2buy.com/license/
* @version    $Id: IndexController.php 6898 2010 YouNet $
* @author     To Anh
*/

class Flashgame_PackageController extends Core_Controller_Action_Standard
{
    protected $_navigation;

    public function init()
    {
        if( !$this->_helper->requireAuth()->setAuthParams('flashgame', null, 'view')->isValid()) return;
    }

    // NONE USER SPECIFIC METHODS
    public function indexAction()
    {

    }
    // Navigation Package
    public function getPackageNavigation($active = false)
    {
        $navigation = $this->_navigation = new Zend_Navigation();
        if( Engine_Api::_()->user()->getViewer()->getIdentity() )
        {  
            /*
            $navigation->addPage(array(
            'label' => Zend_Registry::get('Zend_Translate')->_('Payment History'),
            'route' => 'flashgame_paymenthistory',
            'module' => 'flashgame',
            'controller' => 'package',
            'action' => 'paymenthistory',
            'active' => $active
            ));
            */
            $navigation->addPage(array(
            'label' => Zend_Registry::get('Zend_Translate')->_('My Packages'),
            'route' => 'flashgame_userpackages',
            'module' => 'flashgame',
            'controller' => 'package',
            'action' => 'userpackages'
            ));
            $navigation->addPage(array(
            'label' => Zend_Registry::get('Zend_Translate')->_('Upgrade Packages'),
            'route' => 'flashgame_upgrade',
            'module' => 'flashgame',
            'controller' => 'package',
            'action' => 'upgrade',
            'active' => $active 
            ));
        }
        return $this->_navigation;
    }

    public function upgradeAction()
    {
        $viewer = Engine_Api::_()->user()->getViewer();
        if( !$this->_helper->requireUser()->isValid() ) return;
        $this->view->packages = $packages = Engine_Api::_()->flashgame()->getEnablePackages();
        $this->view->periodtypes = Engine_Api::_()->flashgame()->getPeriodtypes(); 
        $this->view->navigation = $this->getPackageNavigation();
    }
    public function userpackagesAction()
    {
        $viewer = Engine_Api::_()->user()->getViewer();
        if( !$this->_helper->requireUser()->isValid() ) return;
        $this->view->packages = $packages = Engine_Api::_()->flashgame()->getUserPackages($viewer->getIdentity());      
        $this->view->periodtypes = Engine_Api::_()->flashgame()->getPeriodtypes(); 
        $this->view->navigation = $this->getPackageNavigation();
    }

}

